import apiRequest from '@/api/request'

// 获取当前用户菜单
export const getcurrentUserMenusApi = () => {
  return apiRequest.get('/menu/current').then(res => Array.isArray(res) ? res : (res.data || res))
}

// 获取所有菜单
export const getAllMenusApi = (params?: any) => {
  return apiRequest.get('/menu/all', { params }).then(res => Array.isArray(res) ? res : (res.data || res))
}

// 保存菜单
export const saveMenuApi = (data: any) => {
  return apiRequest.post('/menu/save', data).then(res => res.data || res)
}

// 删除菜单
export const deleteMenuApi = (id: number) => {
  return apiRequest.post(`/menu/delete/${id}`).then(res => res.data || res)
}

// 根据ID获取菜单
export const getMenuByIdApi = (id: number) => {
  return apiRequest.get(`/menu/${id}`).then(res => res.data || res)
}